package com.appspot.moviesessions.interfaces.webapp.dto;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;

import javax.xml.bind.annotation.XmlAccessorOrder;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import org.apache.commons.lang.builder.ToStringBuilder;

@XmlRootElement(name = "schedule")
@XmlType(propOrder={"movies","locations","sessions"})
public class Schedule {

	@XmlElementRef(name = "movie")
	private Collection<Movie> movies = new HashSet<Movie>();

	@XmlElementRef(name = "session")
	private Collection<Session> sessions = new ArrayList<Session>();

	@XmlElementRef(name = "location")
	private Collection<Location> locations = new HashSet<Location>();

	public void add(Movie movie) {
		movies.add(movie);
	}

	public Collection<Movie> getMovies() {
		return Collections.unmodifiableCollection(movies);
	}

	public Collection<Session> getSessions() {
		return Collections.unmodifiableCollection(sessions);
	}
	
	public Collection<Location> getLocations() {
	    return Collections.unmodifiableCollection(locations);
    }

	public void add(Session session) {
		sessions.add(session);

	}

	public void add(Location fromLocation) {
		locations.add(fromLocation);
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

}
